package org.example.pipeline;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;

/**
 * @author hh
 * @since 2024/10/20
 */
public class OutPipeline {
    // 内部类，第一个出站处理器
    static class SimpleOutHandlerA extends ChannelOutboundHandlerAdapter {
        @Override
        public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
            System.out.println("出站处理器A：被回调");
            super.write(ctx, msg, promise);
        }
    }

    // 内部类，第二个出站处理器
    static class SimpleOutHandlerB extends ChannelOutboundHandlerAdapter {
        @Override
        public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
            System.out.println("出站处理器B：被回调");
            super.write(ctx, msg, promise);
        }
    }

    // 内部类，第三个出站处理器
    static class SimpleOutHandlerC extends ChannelOutboundHandlerAdapter {
        @Override
        public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
            System.out.println("出站处理器C：被回调");
            super.write(ctx, msg, promise);
        }
    }
}
